package cn.lger.controller.advice;

import cn.lger.controller.LoginController;
import cn.lger.controller.ViewController;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * Code that Changed the World
 *
 * @author Pro
 * @date 2018-06-30.
 */
@ControllerAdvice(assignableTypes = {ViewController.class, LoginController.class})
public class ControllerExceptionHandler {

    @ExceptionHandler(Exception.class)
    public String handler(Exception e, Model model){
        model.addAttribute("msg", e.getMessage());
        model.addAttribute("success", false);
        return "error";
    }

}
